<?php 

namespace App\Models\Power;

use App\Models\Base\PowerBase;

class OperateLog extends PowerBase {

    protected $table = 'cdz_operate_log';

    protected $fillable = [];

    protected $dates = [];

    public static $rules = [
        // Validation rules
    ];

    /**
     * 保存运营分成记录
     * @param int $owner
     * @param string $orderNo
     * @param string $powerRate
     * @param string $serviceRate
     * @param int $type
     * @return bool
     */
    public static function addOperateLog($owner = 0, $orderNo = '', $powerRate = '', $serviceRate = '', $type = 1)
    {
        if ($owner && $orderNo) {
            $query = self::query();
            $insert_data = [
                'type' => $type,
                'date' => date('Ymd'),
                'owner_id' => $owner,
                'order_no' => $orderNo,
                'power_rate' => (string)round($powerRate, 2),
                'service_rate' => (string)round($serviceRate, 2)
            ];
            $re = $query -> insertGetId($insert_data);
            return $re;
        }
        return false;
    }


}
